package com.cn.applet.config;

import javax.sql.DataSource;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.TransactionManagementConfigurer;

/**
 * 事务控制
 * 
 * @author Dai Zhengtao
 * 
 * @date 2018-05-16
 * 
 * */
@Configuration
@EnableTransactionManagement
@MapperScan(value = "com.cn.applet.dao.mapper")
public class TransactionManagement implements TransactionManagementConfigurer{
	
	@Autowired
	private DataSource dataSource;

	@Override
	public PlatformTransactionManager annotationDrivenTransactionManager() {
		
		return new 	DataSourceTransactionManager(dataSource);
	}

}
